home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: [Q] Best way to "define" flag values?
- Message-ID: <marnoldDLKG7E.B3H@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <marnoldDLIv9w.1s4@netcom.com> <cmanDLKAqG.Drt@netcom.com>
- Distribution: na
- Date: Mon, 22 Jan 1996 04:52:25 GMT
- Sender: marnold@netcom9.netcom.com
-
- cman@netcom.com (Mike Austin) writes:
-
- >Here's a little essay that I did a while ago. I still think the same
- >way now, but my views have broadened...
-
- [essay snipped]
-
- Well, after a quick pass, your "enumbit" proposal makes sense to me.
- The C/C++ language certinaly lacks an elegant, type-safe, semi-automatic
- way to deal with flags in a globally consitent way. This shortcoming
- is obviously the source of my original question.
-
- Sure, bit fields are a nice and compact way to store flag values, but
- they do not take the place of hand-tuned #define or enum values used for
- passing flags to functions. You just can't really used bit fields
- conveniently for function parameters.
-
- Sure, you can use enums to declare the values used for flags, but they
- seem to offer little practical advantage over the traditional #define
- approach (yes, enums offer better encapsulation possiblities in C++, but
- they are no more convenient to use in the end than #defines, IMO).
-
- Mike's essay, "Enumerations and Parameterless Macros", paints a nice
- "what if" picture of how flags/bits could be better dealt with in C++ via
- new language support, but it does not really answer my question...
-
- Has any one come up with a good way using the language as it stands?
-
- PS: I did appreciate your posting, Mike.
-
- Thanks,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-